import 'package:lishopflu/base/controller_import.dart';

class ProductDetailCtl extends BaseController{

  ScrollController scrollController = new ScrollController();
  bool showToTopBtn = false; //是否显示“返回到顶部”按钮
  String productId;
  String title = 'ProductDetail';
//  var mList = Rxn<List<String>>();
  final mList = RxList<String>([]);

  @override
  void onFirst() {
    if(appArguments!=null && appArguments.params!=null){
      Map arguments = appArguments.params;
      LiLog.d(arguments);
      productId = arguments[RouterKey.PRODUCT_ID];
      title = arguments[RouterKey.PRODUCT_NAME];
    }

    for(var i=0;i<20;++i) {
      mList.add('data' + mList.length.toString());
    }

    //监听滚动事件，打印滚动位置
    scrollController.addListener(() {
      if (scrollController.offset < 1000 && showToTopBtn) {
          showToTopBtn = false;
      } else if (scrollController.offset >= 1000 && showToTopBtn == false) {
          showToTopBtn = true;
      }
    });
  }

  @override
  void onDestroy() {
    scrollController.dispose();
  }

  void toOrderConfirm() => Get.toNamed(AppPages.ORDER_CONFIRM);

  void toPhoto() => Get.toNamed(AppPages.PHOTO);

  void toSearch() => Get.toNamed(AppPages.HOME_SEARCH);

  void toProductDetail(Map<String, dynamic> params) => Get.toNamed(AppPages.PRODUCT_DETAIL, arguments: AppArguments(params: params));
}